<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
    window.onload = function(){
        var a = document.getElementsByTagName("input");
        a[2].onclick = function(){
            var n = Number(a[0].value);
            var k = Number(a[1].value);
            var str = "";
            var sum = 0;
           
            for(var i = 1; i<=k;i++){
                var cifang = 1;
                for(var j = 1;j<=k;j++){
                    cifang = cifang * i;
                    
                }
                str += i + "^" + k ;
                if(i<k){
                    str +=  "+"; 
                }
                sum =sum + cifang; 
            }
            var b = document.getElementsByClassName("result");
            b[0].innerHTML = str + "=" + sum;
        }
    }
    
    
    </script>
    <style>
        .result{
            width: 500px;
            height: 100px;
            border-style: solid;
            border: 1px solid #000;
            
        }
    </style>
</head>
<body>
    <input type="text" placeholder="请输入n">^
    <input type="text" placeholder="请输入k">=
    <input type="button" value="计算">
    <div class="result"></div>
</body>
</html>